<template>
    <NavBar
        :title="Data.dtbname"
        :isBack="true"
        bgColor="#ffff"
        iconUrl="/ui-prod-2.8.0/back.png"
        fontColor="#333333" />
    <view class="status-content" :style="{ height: `calc(100vh - ${navBarInfo.navbarHeight}px)` }">
        <image :src="getImgOssUrl(iconList[type])" class="status-image"></image>
        <view class="status-apply">{{ statusApply[type] }}</view>
        <view class="status-name" v-if="Data.dtbIdent == 1 && props.type == 0">{{ status[type] }}</view>
        <view class="status-name status-square" v-if="Data.dtbIdent == 1 && [2].includes(type)">{{ Data.reason }}</view>
        <button class="status-button" v-if="Data.dtbIdent == 1 && [2].includes(type)" @click="jumpTo">重新申请</button>
        <button class="status-button" v-if="Data.dtbIdent == 2 && [1].includes(type)" @click="jumpTo">
            {{ `进入${storage.get('dtbName')}中心` }}
        </button>
    </view>
    <weChatPopup :imgSrc="Data?.qyQrcode" :title="Data?.qyName" ref="wechatRef" />
</template>
<script setup>
import { ref, reactive } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import router from '@/router';
import request from '@/request';
import NavBar from '@/components/navBar';
import weChatPopup from '@/components/weChatPopup';
import storage from '@/commons/storage';
import store from '@/store';
import { getImgOssUrl } from '@/commons/utils';
const navBarInfo = store.useNavBarStore();

const props = defineProps({
    //0:审核中，1：审核通过，2：审核拒绝，3：禁用
    type: {
        type: Number,
        default: 0
    }
});
const type = ref();
const wechatRef = ref();
let Data = reactive({
    dtbIdent: 1,
    auditStatus: '1',
    reason: '',
    qySwitch: 1,
    qyName: '',
    qyQrcode: '',
    status: '1', //账号启用状态 状态1 是启用 2 是禁用
    first: 1 //1是首次 2 非首次
});
const iconList = ref([
    '/ui-prod-2.8.0/examine-ing.png',
    '/ui-prod-2.8.0/examine-pass.png',
    '/ui-prod-2.8.0/examine-refuse.png',
    '/ui-prod-2.8.0/forbid.png'
]);
const statusApply = ref(['申请提交成功!', '恭喜您，审核通过!', '商家已拒绝!', '您的账号已被禁用']);
const status = ref(['商家审核中~']);

const jumpTo = () => {
    let url =
        props.type == 2
            ? '/pages-user/distributi/distributiApply/index'
            : '/pages-user/distributi/distributiCenter/index';
    router.redirectTo({ url });
};
onShow(() => {
    Data.dtbname = '申请' + storage.get('dtbName');
    type.value = props.type;
    request('dtbInfo').then(res => {
        Object.assign(Data, res.data);
        if (Data.status != 2) {
            if (Data.auditStatus == 2) {
                type.value = 1;
            }
            if (Data.auditStatus == 2 && Data.qySwitch == 2) {
                wechatRef.value.openPopup();
            }
        }
    });
});
</script>
<style lang="scss" scoped src="./index.scss"></style>
